﻿using AiXiu.BLL;
using AiXiu.Common;
using AiXiu.IBLL;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace AiXiu.Web
{
    /// <summary>
    /// 获取评论列表
    /// </summary>
    public class DiscussListHandler : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            //取值
            string videoId = context.Request.QueryString["id"];
            int pageNumber = int.Parse(context.Request.QueryString["pageNumber"]);
            int pageSize = int.Parse(context.Request.QueryString["pageSize"]);
            //读取列表
            IUserManager userManager = new UserManager();
            List<Model.Redis.Discuss> discusses = userManager.QueryDiscusses(videoId, pageNumber, pageSize);
            //返回结果
            string discussesJson = JsonConvert.SerializeObject(discusses, new UnixDateTimeConverter());
            context.Response.ContentType = "text/plain";
            context.Response.Write(discussesJson);
            context.Response.End();
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}